# Contributor: Tyler A <tylera@privatedemail.net>
# Contributor: ungleich <foss@ungleich.ch>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=ndisc6
pkgver=1.0.5
pkgrel=0
pkgdesc="a small collection of useful tools for IPv6 networking"
url="https://www.remlab.net/ndisc6"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers perl"
subpackages="$pkgname-doc rdnssd rdnssd-openrc:openrc:noarch $pkgname-dnssort::noarch"
source="https://www.remlab.net/files/ndisc6/ndisc6-$pkgver.tar.bz2
	rdnssd.initd
	rdnssd.resolvconf
	rdnssd-fix-merge-hook-regex.patch
	"

build() {
	./configure \
		--build=$BUILD \
		--host=$CHOST \
		--prefix=/usr \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--disable-suid-install
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m755 "$srcdir"/rdnssd.initd "$pkgdir"/etc/init.d/rdnssd
}

dnssort() {
	pkgdesc="ndisc6 dnssort (perl)"
	install_if="$pkgname perl"
	depends=perl
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/dnssort "$subpkgdir"/usr/bin/
}

rdnssd() {
	pkgdesc="autoconfigures the list of DNS servers through slateless IPv6 autoconfiguration"
	amove usr/sbin/rdnssd
	amove etc/rdnssd
	amove var/run/rdnssd

	install -D -m755 "$srcdir"/rdnssd.resolvconf \
		"$subpkgdir"/etc/rdnssd/resolvconf
}

sha512sums="
5a27b78dfb527fd6d0264452b8697f4dcd61758d0c334f7de5daf14198d5bc983027ac49d679630fe35af8ce21349403377385cda188632df859c8218485c843  ndisc6-1.0.5.tar.bz2
7225d35c258bc59c23850811583811e3f62936cc395a010e5e0d32734916dec5f7c434b0915075a26c4670bd218b2e47269b7a685a71eab185766ba614f6f3cf  rdnssd.initd
7b23eafa78bd88d43d0910dbb6cb8d248c00425edb0826571c4d4f9129de33f07093dba4a42f05a549ef1bb9a0fd301716a30bf95ceea18d445e291f0169a444  rdnssd.resolvconf
6e24c20f5b54ed4867ead508e7f85dddc86804441e0876778927e815f4871d31e35e3872e1631b2b147641b18f735dcca9609072217a9e622b10b328b19d2e73  rdnssd-fix-merge-hook-regex.patch
"
